package com.lakers.notice.springboot.netty;

/**
 * 功能描述: CmdType
 *
 * @author liqin(zxl)
 * @date 2024/5/3
 */
public enum CmdType {


    /**
     * 登陆
     */
    LOGIN(0, "登陆"),
    /**
     * 心跳
     */
    HEART_BEAT(1, "心跳"),

    /**
     * 强制下线
     */
    FORCE_LOGOUT(2, "强制下线"),

    /**
     * 消息
     */
   MESSAGE(3, "消息"),

    ;

    private final Integer cmd;

    private final String desc;

    CmdType(Integer cmd, String desc){
        this.cmd = cmd;
        this.desc = desc;
    }

    public Integer getCmd() {
        return cmd;
    }

    public String getDesc() {
        return desc;
    }

    public static CmdType fromCode(Integer code) {
        for (CmdType typeEnum : values()) {
            if (typeEnum.getCmd().equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }
}
